package logic

import (
	"context"
	"shuqi-novel/models"

	"shuqi-novel/novelrpc/internal/svc"
	"shuqi-novel/novelrpc/novelrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type ArticleUpdateLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewArticleUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ArticleUpdateLogic {
	return &ArticleUpdateLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 更新
func (l *ArticleUpdateLogic) ArticleUpdate(in *novelrpc.ArticleUpdateRequest) (*novelrpc.ArticleUpdateResponse, error) {
	// todo: add your logic here and delete this line

	var article models.Article
	if err := article.ArticleUpdate(models.DB); err != nil {
		return nil, err
	}

	return &novelrpc.ArticleUpdateResponse{
		ArticleId: int64(article.ID),
	}, nil
}
